/*Hazard out of job as function of being in complex vs non complex job */

#delimit ;

*version 8;
set mem 100m;
 
log using table8, replace text;
 


/*private sector only*/

use psid76_2004_jleo;


replace tenure=round(tenure);

gen t1=1 if tenure<1;
replace t1=0 if t1==.;

gen t2=1 if tenure>=1 & tenure<2;
replace t2=0 if t2==.;

gen t3=1 if tenure>=2 & tenure<3;
replace t3=0 if t3==.;

gen t4=1 if tenure>3 & tenure<5;
replace t4=0 if t4==.;

gen t5=1 if tenure>5 & tenure<7;
replace t5=0 if t5==.;

gen t6=1 if tenure>=7 & tenure<10;
replace t6=0 if t6==.;

gen t7=1 if tenure>=10 & tenure<15;
replace t7=0 if t7==.;

gen t8=1 if tenure>=15 & tenure<20;
replace t8=0 if t8==.;

gen t9=1 if tenure>=20 & tenure<30;
replace t9=0 if t9==.;

gen t10=1 if tenure>=30;
replace t10=0 if t10==.;



gen failvar=(year<2004);
sort jobmatch year;
by jobmatch: gen dead= failvar & _n==_N;

stset tenure, id(jobmatch) failure(dead);

ta tenure, ge(d); *Create period-specific dummy variables, d*;

ta year, ge(y); *Create period-specific dummy variables, y;

ta ind1dg, ge(indus); *create industry dummies;

ta occcat, ge(occup); *create occ dummies;

gen relat_unemp=relational_job*unemp;




pgmhaz8 relational_job potexp exp2 exp3 educ collbarg married nonwhite
        indus1-indus8 occup1-occup7 
        y1-y18 t1-t9, eform i(jobmatch) s(tenure) d(dead);

pgmhaz8 relational_job unemp relat_unemp
 potexp exp2 exp3 educ collbarg married nonwhite
        indus1-indus8 occup1-occup7 
        y1-y18 t1-t9, eform i(jobmatch) s(tenure) d(dead);


clear;
log close;


